<html>
	<head>
		<title>JS简单计时器练习</title>
		<meta http-equiv="Content-Type content=html.text" charset="utf-8">
		<script>
			var i = 0;
			var string;
			var timer;
			//开始计时
			function start1() {
				// alert('开始');
				if (timer) {
					window.clearTimeout(timer);
				}
				//1.获取id=result的<input>
				var result = document.getElementById("result");
				if (i < 10) {
					i = "0"+i;
				}
				result.value = i+"秒";
				i++;
				timer = window.setTimeout("start1()", 1000);



			}

			//停止计时
			function stop1 () {
				// alert('停止');
				window.clearTimeout(timer);

			}
			//重置时间
			function reset1 () {
				var result = document.getElementById("result");
				window.clearTimeout(timer);
				result.value = "00:00:00";
			}
		</script>
	</head>
	<body>
		<input id="result" type="button" value="">
		<br>
		<input type="button" value="开始" onclick="start1()">
		<input type="button" value="停止" onclick="stop1()">
		<input type="button" value="重置" onclick="reset1()">
	</body>
</html>